package com.nuoniu.sibanyun.controller.erp;


import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.erp.ErpVoucherClass;
import com.nuoniu.sibanyun.service.erp.IErpVoucherClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 凭证类别 前端控制器
 * </p>
 *
 * @author 小啊刚
 * @since 2021-03-31
 */
@RestController
@RequestMapping("/erp/voucherClass")
@Api(tags = "凭证类别管理", value = "凭证类别管理")
public class ErpVoucherClassController extends BaseController {

    @Autowired
    private IErpVoucherClassService voucherClassService;

    @ApiOperation("获取默认列表")
    @GetMapping("getDefaultList")
    public HttpResult<ErpVoucherClass> getDefaultList(Integer classMethod) {
        return HttpResult.ok(voucherClassService.getDefaultList(classMethod));
    }

    @ApiOperation("获取凭证列表")
    @GetMapping("getList")
    public HttpResult<ErpVoucherClass> getList() {
        return HttpResult.ok(voucherClassService.getList());
    }

    @ApiOperation("保存凭证")
    @PostMapping("save")
    public HttpResult save(@RequestBody List<ErpVoucherClass> voucherClass) {
        voucherClassService.saveVoucherClass(voucherClass);
        return HttpResult.ok();
    }

    @ApiOperation("删除凭证")
    @PostMapping("delete")
    public HttpResult delete(@RequestBody List<Long> ids) {
        voucherClassService.deleteByIds(ids);
        return HttpResult.ok();
    }
}
